//---------------------------------------------------------------------------------------------------------------------------------------------------
// <copyright file="MenuController.cs" company="DarkWynter Studios">
//     Copyright (C)2007 DarkWynter Studios.  All rights reserved.
// </copyright>
//---------------------------------------------------------------------------------------------------------------------------------------------------
// {Contact : darkwynter.com for licensing information
//---------------------------------------------------------------------------------------------------------------------------------------------------

namespace DWControllerDemo
{
    using System;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Input;
    using DarkWynter.Engine;
    using DarkWynter.Engine.Controllers;
    using DWControllerDemo;

    /// <summary>
    /// Menu Controller for getting player inputs for the menu system
    /// </summary>
    public class MenuController : Controller
    {
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="playerNumber">Player index for this controller</param>
        public MenuController(int playerNumber)
            : base(playerNumber)
        {
            Add(new KeyboardControl(Keys.Escape, Escape, 100));
            Add(new KeyboardControl(Keys.G, SwitchGameMode, 100));

            Add(new KeyboardControl(Keys.Up, MenuUp, 200));
            Add(new KeyboardControl(Keys.Down, MenuDown, 200));
            Add(new KeyboardControl(Keys.Left, MenuLeft, 200));
            Add(new KeyboardControl(Keys.Right, MenuRight, 200));
        }
        /// <summary>
        /// Constructor for Xbox only controls
        /// </summary>
        /// <param name="playerIndex">Controller index</param>
        public MenuController(PlayerIndex playerIndex)
            : base(playerIndex)
        {
            // Add Xbox controls
        }
        /// <summary>
        /// Constructor for Xbox and keyboard controls
        /// </summary>
        /// <param name="player">Player index in ObjectLibrary</param>
        /// <param name="playerIndex">Player index for this controller</param>
        public MenuController(int player, PlayerIndex playerIndex)
            : base(player, playerIndex)
        {
            Add(new KeyboardControl(Keys.Escape, Escape, 100));
            Add(new KeyboardControl(Keys.M, SwitchGameMode, 100));

            Add(new KeyboardControl(Keys.Up, MenuUp, 200));
            Add(new KeyboardControl(Keys.Down, MenuDown, 200));
            Add(new KeyboardControl(Keys.Left, MenuLeft, 200));
            Add(new KeyboardControl(Keys.Right, MenuRight, 200));


            // Add xbox controls
        }

        private void Escape(ControllerBoolEventArgs args)
        {
            ControllerDemo._self.Exit();
        }
        private void SwitchGameMode(ControllerBoolEventArgs args)
        {
            ControllerDemo._self.gameMode = ControllerDemo.GameMode.Game;
        }
        private void MenuUp(ControllerBoolEventArgs args)
        {
            Vector4 color = ControllerDemo._self.backColor.ToVector4();
            color.X = 1.0f;         // R
            color.Y = 1.0f;         // G
            color.Z = 1.0f;         // B
            ControllerDemo._self.backColor = new Microsoft.Xna.Framework.Graphics.Color(color);
        }
        private void MenuDown(ControllerBoolEventArgs args)
        {
            Vector4 color = ControllerDemo._self.backColor.ToVector4();
            color.X = 0.0f;          // R
            color.Y = 0.0f;         // G
            color.Z = 0.0f;         // B
            ControllerDemo._self.backColor = new Microsoft.Xna.Framework.Graphics.Color(color);
        }
        private void MenuLeft(ControllerBoolEventArgs args)
        {

        }
        private void MenuRight(ControllerBoolEventArgs args)
        {

        }
 
    }
}
